import {Component, OnInit} from '@angular/core';
import {FetchService} from "../../../../core/net/fetch.service";
import {DomSanitizer, SafeResourceUrl} from "@angular/platform-browser";

@Component({
  selector: 'app-report-ggpsg',
  templateUrl: './ggpsg.component.html',
  styleUrls: ['../report.component.scss', './ggpsg.component.scss']
})
export class GgpsgComponent implements OnInit {
  yearValue = 2020;
  monthPickerValue = new Date().getMonth();
  serverUrl = (window as any).environment.reportUrl;
  iframeSrc: SafeResourceUrl;

  constructor(
    private fetchService: FetchService,
    private sanitizer: DomSanitizer
  ) {
  }

  ngOnInit() {
   this.queryInfo();
  }

  queryInfo(): void {
    const year = this.yearValue;
    const month = this.monthPickerValue + 1;
    const token = localStorage.token;
    const link = `${this.serverUrl}preview?_u=wrs:骨干排水沟.ureport.xml&_t=3,6&year=${year}&month=${month}&token=${token}`;
    this.iframeSrc = this.sanitizer.bypassSecurityTrustResourceUrl(link);
  }

  dateChange(): void {
    this.queryInfo();
  }

}

